<template>
  <div class="login-container">
    <el-card header="管理员登录" class="login-card">
      <el-form @submit.native.prevent="adminsLogin">
        <el-form-item label="账号">
          <el-input v-model="model.account"></el-input>
        </el-form-item>
        <el-form-item label="密码">
          <el-input type="password" v-model="model.password"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" native-type="submit">登录</el-button>
        </el-form-item>
      </el-form>
    </el-card>
  </div>
</template>

<script>
export default {
  data(){
    return{
      model:{}
    }
  },
  methods:{
    async adminsLogin(){
      const res=await this.$http.post('/admins/login',this.model);
      console.log(res);
      localStorage.token=res.data.token;
      this.$router.push("/admins");
      this.$message({
        type:'success',
        message:'登录成功'
      })
    }
  }
}
</script>

<style>
  .login-card{
    width:25rem;
    margin:5rem auto;
  }
</style>